﻿@page "/Bas/Supplier/Edit"
@using nERP.ViewModel.Bas.SupplierVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
            <BootstrapInput @bind-Value="@Model.Entity.SupplierCode" />
            <BootstrapInput @bind-Value="@Model.Entity.SupplierName" />
            <BootstrapInput @bind-Value="@Model.Entity.ContactPerson" />
            <BootstrapInput @bind-Value="@Model.Entity.PhoneNumber" />
            <BootstrapInput @bind-Value="@Model.Entity.Email" />
            <BootstrapInput @bind-Value="@Model.Entity.Faxing" />
            <BootstrapInput @bind-Value="@Model.Entity.BeginPay" />
            <BootstrapInput @bind-Value="@Model.Entity.EndPay" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxtRate" />
            <BootstrapInput @bind-Value="@Model.Entity.Remark" />
            <BootstrapInput @bind-Value="@Model.Entity.Address" />
            <BootstrapInput @bind-Value="@Model.Entity.Bank" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxpayerNumber" />
            <BootstrapInput @bind-Value="@Model.Entity.BankAccount" />
            <BootstrapInput @bind-Value="@Model.Entity.LandlinePhone" />
            <WTUploadFile @bind-Value="@Model.Entity.SupplierFile" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]" />
            <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SupplierVM Model = new SupplierVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Bas/Supplier/Edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
    }
    public void OnClose()
    {
        CloseDialog();
    }

    protected override async Task OnInitializedAsync()
    {


        if (id != "")
        {
            var rv = await WtmBlazor.Api.CallAPI<SupplierVM>($"/api/Bas/Supplier/{id}");
            Model = rv.Data;
        }

        await base.OnInitializedAsync();
    }
}
